package com.example.duanjunjie.learn.intentservice;

import android.app.IntentService;
import android.content.Intent;
import android.support.annotation.Nullable;

import com.example.duanjunjie.learn.utils.LogUtil;

/**
 * Created by duanjunjie on 2018/3/2.
 */

public class MyIntentService extends IntentService {

    private volatile int count;

    public MyIntentService() {
        super("MyIntentService");
        LogUtil.i("MyIntentService:" + Thread.currentThread().getName());
    }

    public MyIntentService(String name) {
        super(name);
        LogUtil.i("MyIntentService:" + Thread.currentThread().getName());
    }


    @Override
    protected void onHandleIntent(@Nullable Intent intent) {
        LogUtil.i("onHandleIntent:" + Thread.currentThread().getName());
        try {
            count++;
            LogUtil.i(count + "");
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

}
